import { usePageResponseSuccess } from '~/utils/response';

export default eventHandler((event) => {
  const query = getQuery(event);
  const {
    page = 1,
    pageSize = 10,
    resourceId = '',
    status = '',
    dateRange = '',
  } = query;

  const occupancyRecords = [
    {
      id: '1',
      resourceId: '1',
      resourceName: '豪华套房',
      resourceCode: 'ROOM-001',
      businessType: 'HOTEL',
      customerName: '张三',
      customerPhone: '13800138001',
      startTime: '2024-01-15 14:00:00',
      endTime: '2024-01-15 16:00:00',
      duration: 2,
      status: 'OCCUPIED',
      cost: 2560,
      settlementStatus: 'PENDING',
      createTime: '2024-01-14 10:00:00',
      updateTime: '2024-01-15 16:00:00',
    },
    {
      id: '2',
      resourceId: '2',
      resourceName: '温泉池',
      resourceCode: 'SPA-001',
      businessType: 'HOT_SPRING',
      customerName: '李四',
      customerPhone: '13800138002',
      startTime: '2024-01-15 15:00:00',
      endTime: '2024-01-15 17:00:00',
      duration: 2,
      status: 'OCCUPIED',
      cost: 360,
      settlementStatus: 'PENDING',
      createTime: '2024-01-14 11:00:00',
      updateTime: '2024-01-15 17:00:00',
    },
    {
      id: '3',
      resourceId: '3',
      resourceName: 'VIP包间',
      resourceCode: 'REST-001',
      businessType: 'RESTAURANT',
      customerName: '王五',
      customerPhone: '13800138003',
      startTime: '2024-01-15 18:00:00',
      endTime: '2024-01-15 20:00:00',
      duration: 2,
      status: 'OCCUPIED',
      cost: 1000,
      settlementStatus: 'PENDING',
      createTime: '2024-01-14 12:00:00',
      updateTime: '2024-01-15 20:00:00',
    },
    {
      id: '4',
      resourceId: '4',
      resourceName: '宠物诊疗室',
      resourceCode: 'PET-001',
      businessType: 'PET_MEDICAL',
      customerName: '赵六',
      customerPhone: '13800138004',
      startTime: '2024-01-15 09:00:00',
      endTime: '2024-01-15 10:00:00',
      duration: 1,
      status: 'COMPLETED',
      cost: 200,
      settlementStatus: 'SETTLED',
      createTime: '2024-01-14 09:00:00',
      updateTime: '2024-01-15 10:00:00',
    },
    {
      id: '5',
      resourceId: '5',
      resourceName: '高级技师',
      resourceCode: 'STAFF-001',
      businessType: 'HOT_SPRING',
      customerName: '钱七',
      customerPhone: '13800138005',
      startTime: '2024-01-15 16:00:00',
      endTime: '2024-01-15 17:00:00',
      duration: 1,
      status: 'CANCELLED',
      cost: 0,
      settlementStatus: 'CANCELLED',
      createTime: '2024-01-14 13:00:00',
      updateTime: '2024-01-14 15:00:00',
    },
  ];

  // 模拟搜索过滤
  let filteredRecords = occupancyRecords;

  if (resourceId) {
    filteredRecords = filteredRecords.filter(
      (record) => record.resourceId === resourceId,
    );
  }

  if (status) {
    filteredRecords = filteredRecords.filter(
      (record) => record.status === status,
    );
  }

  return usePageResponseSuccess(page, pageSize, filteredRecords);
});
